home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / mewn1m.zip / CUA.CMD next >
OS/2 REXX Batch file  |  1992-04-17  |  10KB  |  362 lines

  1. ; CUA-feel macros for MicroEMACS 3.11c
  2. ;
  3. ; Pierre Perret - April 1992
  4.  
  5. ; Uses mark9 as CUA anchor and mark8 as a temporary (for mark swapping).
  6. ; Uses the Clipboard for CUA copy/cut/paste in MS-Windows version (MEWxx),
  7. ; uses the kill buffer for same in other implementations.
  8.  
  9. ; NOTE:
  10. ; - some key sequences are not supported by MicroEMACS-DOS:
  11. ;     Shift+Arrow, Ctrl+Ins/Del and Shift+Ins/Del/Home/End/PageUp/PageDown.
  12. ; - Shift+Ctrl+Arrow/Home/End not supported by either MicroEMACS-DOS or MEW10.
  13. ; To offset that, the special keys have been assigned equivalent function
  14. ; keys: Ins=F9, Del=F10, Home=F1, End=F2, PageUp=F3, PageDown=F4,
  15. ;       ArrowLeft=F5, ArrowUp=F6, ArrowDown=F7, ArrowRight=F8
  16. ; for Shift or Ctrl combinations (using Alt for Shift+Ctrl cases)
  17.  
  18. ; set $hilite 9     ; for future MEW version that will be able to
  19. ;                   ; show region9 hilited
  20.  
  21. store-procedure CUA-cmdhook
  22. ; NOTE: unfortunately, %keepanchor is always set to FALSE for
  23. ;       M- and ^X prefixed keystrokes, regardless of the binding
  24.     !if %keepanchor
  25.         set %keepanchor FALSE
  26.     !else
  27.         set %discmd $discmd
  28.         set $discmd FALSE
  29.         ; previous command was not an anchor-preserving one
  30.         !force 9 remove-mark
  31.         set $discmd %discmd
  32.     !endif
  33. !endm
  34. set $cmdhook CUA-cmdhook
  35.  
  36. store-procedure load-anchor
  37. ; loads the anchor (mark9) into the mark0, saving
  38. ; previous mark0 into mark8.
  39. ; flag %anchor is set if there is a non-empty selection
  40. ; used by most deletion/copying actions
  41.     set %discmd $discmd
  42.     set $discmd FALSE
  43.     !force 0 exchange-point-and-mark
  44.     !if $status
  45.         8 set-mark
  46.         0 exchange-point-and-mark
  47.     !else
  48.         !force 8 remove-mark
  49.     !endif
  50.     !force 9 exchange-point-and-mark
  51.     !if $status
  52.         0 set-mark
  53.         9 exchange-point-and-mark
  54.         !if &seq $region ""
  55.             set %anchor FALSE
  56.         !else
  57.             set %anchor TRUE
  58.         !endif
  59.     !else
  60.         !force 0 remove-mark
  61.         set %anchor FALSE
  62.     !endif
  63.     set $discmd %discmd
  64. !endm
  65.  
  66. store-procedure restore-mark
  67. ; restores mark0 from mark8 after a load-anchor call
  68.     set %discmd $discmd
  69.     set $discmd FALSE
  70.     !force 8 exchange-point-and-mark
  71.     !if $status
  72.         0 set-mark
  73.         8 exchange-point-and-mark
  74.     !else
  75.         !force 0 remove-mark
  76.     !endif
  77.     set $discmd %discmd
  78. !endm
  79.  
  80. store-procedure CUA-Del
  81.     run load-anchor
  82.     !if %anchor
  83.         kill-region
  84.     !else
  85.         !force 1 delete-next-character
  86.     !endif
  87.     run restore-mark
  88. !endm
  89. macro-to-key    CUA-Del     FND
  90.  
  91. store-procedure CUA-C-Ins
  92.     run load-anchor
  93.     !if %anchor
  94.         set %keepanchor TRUE
  95.         !if &seq $sres MSWIN
  96.             clip-region
  97.         !else
  98.             copy-region
  99.         !endif
  100.     !endif
  101.     run restore-mark
  102. !endm
  103. macro-to-key    CUA-C-Ins    FN^C
  104. macro-to-key    CUA-C-Ins    FN^9
  105. !if &seq $sres MSWIN
  106.     unbind-menu     ">&Edit>&Clipboard>&Copy region"
  107.     macro-to-menu   CUA-C-Ins    "&Copy@1"
  108. !endif
  109.  
  110. store-procedure CUA-S-Del
  111.     run load-anchor
  112.     !if %anchor
  113.         !if &seq $sres MSWIN
  114.             cut-region
  115.         !else
  116.             kill-region
  117.         !endif
  118.     !endif
  119.     run restore-mark
  120. !endm
  121. macro-to-key    CUA-S-Del    S-FND
  122. macro-to-key    CUA-S-Del    S-FN0
  123. !if &seq $sres MSWIN
  124.     unbind-menu     ">&Edit>&Clipboard>Cu&t region"
  125.     macro-to-menu   CUA-S-Del   "Cu&t@0"
  126. !else
  127.  
  128. bind-to-key     yank            S-FNC   ; Shift+Ins
  129. bind-to-key     yank            S-FN9
  130. !endif
  131.  
  132.  
  133. store-procedure CUA-case-upper
  134.     run load-anchor
  135.     !if %anchor
  136.         set %keepanchor TRUE
  137.         case-region-upper
  138.     !endif
  139.     run restore-mark
  140. !endm
  141. macro-to-key    CUA-case-upper  A-U ; Alt+U
  142. !if &seq $sres MSWIN
  143.     macro-to-menu   CUA-case-upper  ">&Edit>&Selection@4>&Upper case"
  144. !endif
  145.  
  146. store-procedure CUA-case-lower
  147.     run load-anchor
  148.     !if %anchor
  149.         set %keepanchor TRUE
  150.         case-region-lower
  151.     !endif
  152.     run restore-mark
  153. !endm
  154. macro-to-key    CUA-case-lower  A-L ; Alt+L
  155. !if &seq $sres MSWIN
  156.     macro-to-menu   CUA-case-lower  "&Lower case"
  157. !endif
  158.  
  159. store-procedure CUA-count-words
  160. ; this procedure is not really necessary but it demonstrates
  161. ; how to add CUA-based functionality
  162.     run load-anchor
  163.     !if %anchor
  164.         set %keepanchor TRUE
  165.         count-words
  166.     !endif
  167.     run restore-mark
  168. !endm
  169. macro-to-key    CUA-count-words A-W ; Alt+W
  170. !if &seq $sres MSWIN
  171.     macro-to-menu   CUA-count-words "Count &words"
  172. !endif
  173.  
  174. store-procedure CUA-flip-selection
  175. ; a sort of exchange-point-and-anchor, could be used to
  176. ; visualize the selection by going back and forth to its
  177. ; boundaries
  178.     !force 9 exchange-point-and-mark
  179.     !if $status
  180.         set %keepanchor TRUE
  181.     !endif
  182. !endm
  183. macro-to-key    CUA-flip-selection A-=
  184. !if &seq $sres MSWIN
  185.     bind-to-menu    nop "-"
  186.     macro-to-menu   CUA-flip-selection "&Flip"
  187. !endif
  188.  
  189. store-procedure CUA-select-region
  190. ; makes the anchor equal to the mark
  191. ; (useful to build very large selections)
  192.     set %discmd $discmd
  193.     set $discmd FALSE
  194.     !force 0 exchange-point-and-mark
  195.     !if $status
  196.         9 set-mark
  197.         0 exchange-point-and-mark
  198.         set %keepanchor TRUE
  199.     !else
  200.         9 remove-mark
  201.     !endif
  202.     set $discmd %discmd
  203. !endm
  204. macro-to-key    CUA-select-region A-^M  ; Alt+Enter
  205. !if &seq $sres MSWIN
  206.     macro-to-menu   CUA-select-region   "Select ®ion"
  207. !endif
  208.  
  209. store-procedure CUA-anchor
  210. ; makes sure we have a CUA anchor point (i.e. a mark9)
  211. ; used internally by most extended selection keys
  212. ; always sets %keepanchor to TRUE
  213.     set %discmd $discmd
  214.     set $discmd FALSE
  215.     !force 9 exchange-point-and-mark
  216.     !if $status
  217.         9 exchange-point-and-mark
  218.     !else
  219.         9 set-mark
  220.     !endif
  221.     set %keepanchor TRUE
  222.     set $discmd %discmd
  223. !endm
  224.  
  225. store-procedure CUA-S-home
  226.     run CUA-anchor
  227.     beginning-of-line
  228. !endm
  229. macro-to-key    CUA-S-home          S-FN<
  230. macro-to-key    CUA-S-home          S-FN1
  231.  
  232. store-procedure CUA-S-end
  233.     run CUA-anchor
  234.     end-of-line
  235. !endm
  236. macro-to-key    CUA-S-end           S-FN>
  237. macro-to-key    CUA-S-end           S-FN2
  238.  
  239. store-procedure CUA-SC-home
  240.     run CUA-anchor
  241.     beginning-of-file
  242. !endm
  243. macro-to-key    CUA-SC-home         S-FN^<
  244. macro-to-key    CUA-SC-home         A-FN1
  245.  
  246. store-procedure CUA-SC-end
  247.     run CUA-anchor
  248.     end-of-file
  249. !endm
  250. macro-to-key    CUA-SC-end          S-FN^>
  251. macro-to-key    CUA-SC-end          A-FN2
  252.  
  253. store-procedure CUA-S-pageup
  254.     run CUA-anchor
  255.     previous-page
  256. !endm
  257. macro-to-key    CUA-S-pageup        S-FNZ
  258. macro-to-key    CUA-S-pageup        S-FN3
  259.  
  260. store-procedure CUA-S-pagedown
  261.     run CUA-anchor
  262.     next-page
  263. !endm
  264. macro-to-key    CUA-S-pagedown      S-FNV
  265. macro-to-key    CUA-S-pagedown      S-FN4
  266.  
  267. store-procedure CUA-S-up
  268.     run CUA-anchor
  269.     !force previous-line
  270. !endm
  271. macro-to-key    CUA-S-up            S-FNP
  272. macro-to-key    CUA-S-up            S-FN6
  273.  
  274. store-procedure CUA-S-down
  275.     run CUA-anchor
  276.     !force next-line
  277. !endm
  278. macro-to-key    CUA-S-down          S-FNN
  279. macro-to-key    CUA-S-down          S-FN7
  280.  
  281. store-procedure CUA-S-left
  282.     run CUA-anchor
  283.     !force backward-character
  284. !endm
  285. macro-to-key    CUA-S-left          S-FNB
  286. macro-to-key    CUA-S-left          S-FN5
  287.  
  288. store-procedure CUA-S-right
  289.     run CUA-anchor
  290.     !force forward-character
  291. !endm
  292. macro-to-key    CUA-S-right         S-FNF
  293. macro-to-key    CUA-S-right         S-FN8
  294.  
  295. store-procedure CUA-SC-left
  296.     run CUA-anchor
  297.     !force previous-word
  298. !endm
  299. macro-to-key    CUA-SC-left         S-FN^B
  300. macro-to-key    CUA-SC-left         A-FN5
  301.  
  302. store-procedure CUA-SC-right
  303.     run CUA-anchor
  304.     !force next-word
  305. !endm
  306. macro-to-key    CUA-SC-right        S-FN^F
  307. macro-to-key    CUA-SC-right        A-FN8
  308.  
  309. bind-to-key     beginning-of-file   FN^<
  310. bind-to-key     beginning-of-file   FN^1    ; for consistency only
  311. bind-to-key     end-of-file         FN^>
  312. bind-to-key     end-of-file         FN^2    ; for consistency only
  313. bind-to-key     beginning-of-line   FN<
  314. bind-to-key     end-of-line         FN>
  315.  
  316. ; Transfer the standard MicroEMACS left mouse button commands onto the 
  317. ; right button (text scrolling, window resizing, screen move/resize...)
  318. ; and the old right button commands to Shift + right button
  319. !force unbind-key  MS1  ; should have been MS^A anyway!
  320. bind-to-key mouse-move-down     MSe     ; right_button_down
  321. bind-to-key mouse-move-up       MSf     ; right_button_up
  322. bind-to-key mouse-resize-screen MS^E    ; Ctrl + right_button_down
  323. bind-to-key mouse-region-down   MSE     ; Shift + right_button_down
  324. bind-to-key mouse-region-up     MSF     ; Shift + right_button_up
  325.  
  326. store-procedure MSleft-down
  327.     set %discmd $discmd
  328.     set $discmd FALSE
  329.     !force mouse-move-down
  330.     !if $status
  331.         set %keepanchor TRUE
  332.         9 set-mark
  333.         set %msbuf $cbufname
  334.     !else
  335.         set %msbuf ""
  336.         !force 9 remove-mark
  337.     !endif
  338.     set $discmd %discmd
  339. !endm
  340. macro-to-key MSleft-down    MSa
  341.  
  342. store-procedure MSleft-up
  343.     set %discmd $discmd
  344.     set $discmd FALSE
  345.     !force mouse-move-down
  346.     !if &and $status &seq %msbuf $cbufname
  347.         set %keepanchor TRUE
  348.     !else
  349.         !force 9 remove-mark
  350.     !endif
  351.     set $discmd %discmd
  352. !endm
  353. macro-to-key MSleft-up      MSb
  354.  
  355. store-procedure S-MSleft
  356.     run CUA-anchor
  357.     !force mouse-move-down  
  358. !endm
  359. macro-to-key S-MSleft       MSA
  360. macro-to-key S-MSleft       MSB
  361.